fix: Fixed SG with prefix lists#271
Merged
Merged
Conversation
Custom rules with prefix lists were failing in cases where no CIDR block was specified due to an edge case in the variable interpolation. If both the rule and the general CIDR block variables are unset, the interpolation returns a list with an empty string as the only element (instead of an empty list). `main.tf` has been modified to add a check for this edge case and return an empty list.
|
This PR has been automatically marked as stale because it has been open 30 days |
|
@antonbabenko Can we have this one merged/reviewed please? |
antonbabenko
pushed a commit
that referenced
this pull request
Jan 13, 2023
### [4.17.1](v4.17.0...v4.17.1) (2023-01-13) ### Bug Fixes * Fixed SG with prefix lists ([#271](#271)) ([fdd67cd](fdd67cd))
Member
|
This PR is included in version 4.17.1 🎉 |
1 task
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Custom rules with prefix lists were failing in cases where no CIDR block was specified due to an edge case in the variable interpolation.
If both the rule and the general CIDR block variables are unset, the interpolation returns a list with an empty string as the only element (instead of an empty list).
main.tfhas been modified to add a check for this edge case and return an empty list.Description
The eight (8) resources in
main.tfwhich set thecidr_blocksoripv6_cidr_blocksargument have been modified to include a check for the edge case where both the custom rule does not include a CIDR block and the corresponding global CIDR block variable is unset (defaulting to an empty list). These resources now correctly evaluate their respective CIDR block arguments to an empty list, allowing the rules to be created with the assigned prefix list id(s).All eight (8) changes follow the pattern below (in pseudo-code):
This preserves the original behavior in all cases except for the edge case, which now returns an empty list.
Motivation and Context
As of v4.16.2, the module does not allow for custom rules to be specified without a CIDR block, even if provided one or more prefix list ids. This appears to be due to a variable interpolation edge case, which is incorrectly returning a list with an empty string (i.e.
[""]) instead of an empty list (i.e.[]). A check has been added to override the interpolation and return an empty list for this edge case, which allows the security group and SG rule(s) to be created as expected.Link to issue: #270
Fixes #270
Breaking Changes
All changes are backwards-compatible; I believe this can be safely released as a bug fix.
How Has This Been Tested?
This change has been tested against my code base.
examples/*to demonstrate and validate my change(s)examples/*projectspre-commit run -aon my pull request